#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <map>
#include <algorithm>

int MAX_NUM = 100000;
//std::map<uint32_t, uint32_t> LUCKYS {{0, 0}, {50, 1}, {100, 10}, {200, 100}, {500, 500}, {600, 1000}, {700, 1500}, {800, 2000}, {1000, 5000}, {1500, 10000}, {2000, 100000}};
std::map<uint32_t, uint32_t> LUCKYS {{0, 0}, {600, 1000}, {700, 1500}, {800, 2000}, {1000, 5000}, {1500, 10000}, {2000, 100000}};

int my_random()
{
    return (rand() % MAX_NUM) + 1;
}

uint32_t get_lucky(uint32_t param)
{
    auto sit = std::find_if(LUCKYS.rbegin(), LUCKYS.rend(), [param](std::map<uint32_t, uint32_t>::value_type& it) {return it.first <= param;});
    if (sit == LUCKYS.rend()) return 0;

    return sit->second;
}

int main(int argc, const char **argv) {
    srand(time(NULL));

    uint32_t lucky = 0;
    std::map<uint32_t , uint32_t> maps;
    for (int i = 0; i < 100000; ++i) {
        uint32_t lw = get_lucky(lucky);
        if (lw <= 0)
        {
            ++lucky;
            continue;
        }
        for (int j = 0; j < 50; ++j) {
            my_random();
        }
        uint32_t tw = my_random();
        printf("lucky:%d, lw:%d, tw:%d\n", lucky, lw, tw);
        if (tw <= lw)
        {
            lucky = 0;
            maps[i + 1] += 1;
        }

        ++lucky;
    }

    uint32_t pre = 0;
    for (const auto& it : maps) {
        uint32_t result = pre == 0 ? it.first : it.first - pre;
        printf("%d\n", result);
        pre = it.first;
    }

    return 0;
}
